<html>
<head>
<title> Registration Form </title>
<style>
body
{

font-family: "Lucida Sans Unicode", "Lucida Grande", Sans-Serif;
color: #036;

}
</style>
</head>
<body>
<div id = "headerwrapper">

	<table id = "headerTable">
		<tr>
			<td>
				<img id = "unoLogo" src="Logo1.jpg" /> 
			</td>
			<td>
		<font size ="6.5"> Department of Computer Science </font>
				
			</td>
			<td>
			</td>

			
		</tr>
	</table>

	<div>
	</br>
	</br>
	</br>
<form method='post' action='registration.php'>
<table width='400' border='5' align='center'>
<tr>

<td colspan= '5' align= 'center'> <h1> Registration Form </h1></td>
</tr>

<tr>

<td align= 'center'>User Name </td>
<td><input type ='text' name='name' /></td>
</tr>
<tr>

<td align= 'center'>User Password</td>
<td ><input type='password' name='pass'/></td>
</tr>
<tr>

<td align= 'center'>Email </td>
<td><input type ='text' name='email' /></td>
</tr>
<tr>

<td align= 'center'>UNO ID</td>
<td><input type=' text' name='unoid'/></td>
</tr>

<tr>
<td align= 'center'>Advising Form </td>
<td>
				<select name = 'aform'>
						<option> </option>
						<option>Thesis</option>
					<option>Non-Thesis</option>
				</select>
			</td>


</tr>

<tr>

<td colspan='5' align='center'><input type='submit' name='submit' value='Sign Up' /></td>

</tr>

</table>
</form>
<center><b>Already Registered </b></br><a href='login.php'>Login Here</a></center>
</body>
</html>

<?php

mysql_connect("localhost","root","");
mysql_select_db("db4208");


if(isset($_POST['submit'])){
 $user_name=$_POST['name'];
 $user_pass=$_POST['pass'];
 $user_email=$_POST['email'];
 $user_unoid=$_POST['unoid'];
$user_aform = $_POST['aform'];
if($user_name==''){
echo " <script> alert('Please enter your Name')</script>";
exit();
}
if($user_pass==''){
echo " <script> alert('Please enter your Password')</script>";
exit();
}
if($user_email==''){
echo " <script> alert('Please enter your Email')</script>";
exit();
}
if($user_unoid==''){
echo " <script> alert('Please enter your UNO ID')</script>";
exit();
}
if($user_aform==''){
echo " <script> alert('Please select Advising form')</script>";
exit();
}
$check_email="select * from users where user_email='$user_email'";
$run=mysql_query($check_email);

if(mysql_num_rows($run)>0){

echo " <script> alert('Email $user_email is already exist in our database please try another one')</script>";
exit();
}
$check_unoid="select * from users where user_id='$user_unoid'";
$run1=mysql_query($check_unoid);

if(mysql_num_rows($run1)>0){

echo " <script> alert('ID $user_unoid is already exist in our database please try another one')</script>";
exit();
}
$query=" insert into users (user_name,user_pass,user_email,user_id,user_aform) values ('$user_name','$user_pass','$user_email','$user_unoid','$user_aform') ";
if(mysql_query($query))
{
if($user_aform=="Non-Thesis")
{
echo " <script> window.open('nonThesis.html','self')</script>";
}
else{
echo " <script> window.open('Thesis.php','self')</script>";
}
}


}



?>

